package com.manbearpig.todue;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
/**
Main class that runs when the application is launched
**/
public class EnterAddressActivity extends Activity
{
	String street;
	String city;
	String state;
	String zip;
	
	
	
	/** Called when the activity is first created. */
    @Override
	/**
	Method that runs when the app is launched for the first time
	@param savedInstanceState the state of the app the last time it was launched
	**/
    public void onCreate(Bundle savedInstanceState) 
    {

    	
        super.onCreate(savedInstanceState);
        setContentView(R.layout.enter_address_layout);
        
        

        
        final Button add_button = (Button) findViewById(R.id.add_location_Button);
        add_button.setText("View Location");
        add_button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	
            	street = ((EditText) findViewById(R.id.street_editText)).getText().toString();
            	city = ((EditText) findViewById(R.id.city_editText)).getText().toString();
            	state = ((EditText) findViewById(R.id.state_editText)).getText().toString();
            	zip = ((EditText) findViewById(R.id.zip_editText)).getText().toString();

            	
                // Perform action on click
            	Log.d("Enter Address", "Attempting to execute the mapview");
            	Log.d("Enter Address", "Address: " + street + " " + city + " " + state + " " + zip);
            	Intent myIntent = new Intent(getApplicationContext(), HelloGoogleMapsActivity.class);
			    //myIntent.putExtra("Username", this.username);
            	myIntent.putExtra("Street", street);
            	myIntent.putExtra("City", city);
            	myIntent.putExtra("State", state);
            	myIntent.putExtra("Zip", zip);
            	
        		startActivity(myIntent);
            }
        });
        
        final Button cancel_button = (Button) findViewById(R.id.cancel_location_add_button);
        cancel_button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
            	finish();
            }
        });
        
        
        
    }
    
    /**
     * OnClickListener for displaying the map
     * @param view the requested view
     */
    public void onClick(View view)
    {
    	Intent myIntent = new Intent(getApplicationContext(), HelloGoogleMapsActivity.class);
        startActivity(myIntent);   
    }
}